package com.example.repair_service.controller.user;

import com.example.repair_service.entity.CategoryEntity;
import com.example.repair_service.result.Result;
import com.example.repair_service.service.CategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user/category")
@Tag(name = "C端用户服务分类相关接口")
@Slf4j
public class CategoryController {

    @Autowired
    public CategoryService categoryService;

    @GetMapping("/list")
    @Operation(summary = "一级菜单分类查询")
    public Result<List<CategoryEntity>> level1Menu(){
        List<CategoryEntity> list = categoryService.getList();
        log.info("一级菜单分类查询:{}", list);
        return Result.success(list);
    }

    @GetMapping("/list/{parentId}")
    @Operation(summary = "二级菜单分类查询")
    public Result<List<CategoryEntity>> level2Menu(@PathVariable("parentId") Long parentId){
        List<CategoryEntity> list = categoryService.getList(parentId);
        log.info("二级菜单分类查询:{}", list);
        return Result.success(list);
    }




}
